home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / as / RCS / as_front.c,v < prev   
Encoding:
Text File  |  1990-08-09  |  3.0 KB  |  156 lines

  1. head     1.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    rab:1.2; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.2
  10. date     90.08.06.21.07.58;  author rab;  state Exp;
  11. branches ;
  12. next     1.1;
  13.  
  14. 1.1
  15. date     90.07.25.15.19.38;  author rab;  state Exp;
  16. branches ;
  17. next     ;
  18.  
  19.  
  20. desc
  21. @@
  22.  
  23.  
  24. 1.2
  25. log
  26. @Added symm.
  27. @
  28. text
  29. @/* 
  30.  * as.c --
  31.  *
  32.  *    Front end for assembler.
  33.  *
  34.  * Copyright 1989 Regents of the University of California
  35.  * Permission to use, copy, modify, and distribute this
  36.  * software and its documentation for any purpose and without
  37.  * fee is hereby granted, provided that the above copyright
  38.  * notice appear in all copies.  The University of California
  39.  * makes no representations about the suitability of this
  40.  * software for any purpose.  It is provided "as is" without
  41.  * express or implied warranty.
  42.  */
  43.  
  44. #ifndef lint
  45. static char rcsid[] = "$Header: /sprite/src/cmds/as/RCS/as_front.c,v 1.1 90/07/25 15:19:38 rab Exp Locker: rab $";
  46. #endif /* not lint */
  47.  
  48. #include <stdio.h>
  49. #include <string.h>
  50. #include <stdlib.h>
  51. #include <sys/param.h>
  52. #include <assert.h>
  53.  
  54. #ifndef __STDC__
  55. #define const
  56. #endif
  57.  
  58. #ifndef EXIT_FAILURE
  59. #define EXIT_FAILURE    1
  60. #endif
  61.  
  62. #ifdef sun3
  63. static const char *hostMachine = "sun3";
  64. #else
  65. #ifdef sun4
  66. static const char *hostMachine = "sun4";
  67. #else
  68. #ifdef ds3100
  69. static const char *hostMachine = "ds3100";
  70. #else
  71. #ifdef symm
  72. static const char *hostMachine = "symm";
  73. #else
  74. NO DEFAULT TARGET MACHINE TYPE DEFINED
  75. #endif
  76. #endif
  77. #endif
  78. #endif
  79.  
  80. /*
  81.  *----------------------------------------------------------------------
  82.  *
  83.  * main --
  84.  *      Search through the command line arguments looking for an argument
  85.  *      of the form -mfoo, where `foo' is a machine type.  If found, delete
  86.  *      it from the list of arguments, and use it to determine which
  87.  *      backend to exec.  If there is no -m then default to the type
  88.  *      of the host machine.
  89.  *
  90.  * Results:
  91.  *    None.
  92.  *
  93.  * Side effects:
  94.  *    Execs machine assembler backend.
  95.  *
  96.  *----------------------------------------------------------------------
  97.  */
  98.  
  99. void
  100. main(argc, argv)
  101.     int argc;
  102.     char **argv;
  103. {
  104.     extern int errno;
  105.     int i;
  106.     int j;
  107.     const char *targetMachine;
  108.     char path[MAXPATHLEN];
  109.  
  110.     assert(argv[argc] == NULL);
  111.     targetMachine = hostMachine;
  112.     for (i = 1; i < argc; ++i) {
  113.     if (argv[i][0] == '-' && argv[i][1] == 'm') {
  114.         if (argv[i][2] == '\0') {
  115.         targetMachine = argv[i + 1];
  116.         if (targetMachine == NULL) {
  117.             fprintf(stderr, "No target machine specified\n");
  118.             exit(EXIT_FAILURE);
  119.         }
  120.         for (j = i; j < argc - 1; ++j) {
  121.             argv[j] = argv[j + 2];
  122.         }
  123.         argc -= 2;
  124.         assert(argv[argc] == NULL);
  125.         } else {
  126.         targetMachine = argv[i] + 2;
  127.         for (j = i; j < argc; ++j) {
  128.             argv[j] = argv[j + 1];
  129.         }
  130.         --argc;
  131.         assert(argv[argc] == NULL);
  132.         }
  133.         break;
  134.     }
  135.     }
  136.     sprintf(path, "/sprite/lib/gcc/%s.md/as.%s", hostMachine, targetMachine);
  137.     execv(path, argv);
  138.     fprintf(stderr, "Can't exec ``%s'': %s\n", path, strerror(errno));
  139.     exit(EXIT_FAILURE);
  140. }
  141.  
  142. @
  143.  
  144.  
  145. 1.1
  146. log
  147. @Initial revision
  148. @
  149. text
  150. @d17 1
  151. a17 1
  152. static char rcsid[] = "$Header$";
  153. d43 3
  154. d47 1
  155. @
  156.